package com.gw.vip.server.controller;

import com.gw.vip.common.log.PrintlnLog;
import com.gw.vip.common.vo.Result;
import com.gw.vip.server.dto.*;
import com.gw.vip.server.service.PanService;
import com.gw.vip.server.sign.RequiredSign;
import com.gw.vip.server.vo.AmtQueryVo;
import com.gw.vip.server.vo.PanAmtQueryVo;
import com.gw.vip.server.vo.PanResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author GW 光武
 * @description
 * @since 2023-03-25
 */
@RestController
@RequestMapping("pan")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PanController {

    private final PanService panService;

    @PrintlnLog(description = "开卡")
    @PostMapping("open")
    public Result panOpen(@RequestBody @Valid PanOpenDto dto){
        PanResponse vo = panService.panOpen(dto);
        return Result.success(vo);
    }

    @PrintlnLog(description = "消费")
    @PostMapping("sale")
    public Result panSale(@RequestBody @Valid PanSaleDto dto){
        PanResponse vo = panService.panSale(dto);
        return Result.success(vo);
    }

    @PrintlnLog(description = "退款")
    @PostMapping("refund")
    public Result panRefund(@RequestBody @Valid PanRefundDto dto){
        PanResponse vo = panService.panRefund(dto);
        return Result.success(vo);
    }

    @PrintlnLog(description = "主账户余额查询")
    @PostMapping("amtQuery")
    @RequiredSign
    public Result amtQuery(@RequestBody @Valid PanAmtQueryDto dto){
        PanAmtQueryVo vo = panService.amtQuery(dto);
        return Result.success(vo);
    }
}
